package com.giscloud.limp.controller;

import java.util.Arrays;

import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.beans.factory.annotation.Autowired;

import com.giscloud.limp.entity.CaseWarn;
import com.giscloud.limp.service.CaseWarnService;
import com.giscloud.limp.entity.dto.CaseWarnDTO;
import com.giscloud.datasource.page.PageInfo;
import com.giscloud.commons.model.Result;
import lombok.extern.log4j.Log4j2;
import org.springframework.web.bind.annotation.*;


/**
 * 案件提醒
 *
 * @author giscloud
 * @email giscloud@giscloud.com
 * @date 2020-06-10 14:25:30
 */
@RestController
@RequestMapping("/limp/casewarn")
@Log4j2
public class CaseWarnController {

    private final CaseWarnService caseWarnService;

    @Autowired
    public CaseWarnController(CaseWarnService caseWarnService) {
        this.caseWarnService = caseWarnService;
    }
    /**
     * 列表
     */
    @RequestMapping("/list")
    public Result<PageInfo<CaseWarn>> list(@RequestBody CaseWarnDTO caseWarnDTO){
        PageInfo page = caseWarnService.queryPage(caseWarnDTO);
        return Result.success(page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{caseWarnId}")
    public Result<CaseWarn> info(@PathVariable("caseWarnId") Integer caseWarnId){
		CaseWarn caseWarn = caseWarnService.getById(caseWarnId);
        return Result.success(caseWarn);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    public Result save(@RequestBody CaseWarn caseWarn){
        return caseWarnService.save(caseWarn);
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    public Result update(@RequestBody CaseWarn caseWarn){
        return caseWarnService.updateById(caseWarn);
    }

    /**
     * 删除(直接传数组对象即可，如：[1],[1,2]支持批量删除)
     */
    @RequestMapping("/delete")
    public Result delete(@RequestBody Integer[] caseWarnIds){
        return caseWarnService.removeByIds(Arrays.asList(caseWarnIds));
    }

}
